﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.DataVisualization.Charting;

using IdeaNMR.Shared;

namespace IdeaNMR.Web
{
    public partial class DisplayBenchmark : System.Web.UI.UserControl
    {
        public Point[] Data { get; set; }

        public string Dimension { get; set; }

        public int Width { get; set; }
        public int Height { get; set; }

        public string CssClass { get; set; }

        protected void Page_Load(object sender, EventArgs e)
        {
            MainChart.CssClass = this.CssClass;

            MainChart.Width = this.Width;
            MainChart.Height = this.Height;
            MainChart.Titles["DefaultTitle"].Text = string.Format("{0} Dimension", this.Dimension);

            // ALISTAIR modified 19/08/2011
            // For data visualisation, only using real portion of value
            foreach (Point p in this.Data)
            {
                MainChart.Series["Spectrum"].Points.AddXY(p.T, (double)p.V.Real);
            }

            MainChart.Series["Spectrum"].ChartType = SeriesChartType.Spline;

            // ALISTAIR added 24/09/2012
            // Diagnostic output for debugging
            /*
            String diagnosticOutput = "Points in Spectrum:\n";
            diagnosticOutput += "Freq(ppm),Amplitude\n";
            
            foreach (Point p in this.Data)
            {
                diagnosticOutput += p.T.ToString() + "," + (double)p.V.Real + "\n";
            }
            System.Diagnostics.Debug.WriteLine(diagnosticOutput);
            */
        }
    }
}